package com.dailyblue.project.estate.controller;

import com.dailyblue.project.estate.commons.bean.Device;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.service.DeviceService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:DeviceController
 * @Date:2025/9/18 15:28
 */
@RestController
@RequestMapping("/device")
public class DeviceController {
    @Resource
    private DeviceService deviceService;
    @PostMapping
    JsonResult saveDevice(Device device) {
        return deviceService.saveDevice(device);
    }

    @GetMapping("/{id}")
    JsonResult findOne(@PathVariable("id")String id) {
        return deviceService.findOne(id);
    }

    @GetMapping
    JsonResult findAll(){
        return deviceService.findAllDevice();
    }
    @DeleteMapping("/{id}")
    JsonResult deleteOne(@PathVariable("id")String id) {
        return deviceService.deleteDevice(id);
    }
    @PutMapping
    JsonResult updateOne(@RequestBody Device device) {
        return deviceService.updateDevice(device);
    }
}
